
import { useState } from "react";
function Counter() {
  // State: counter 值
  const [counter, setCounter] = useState(0);

  // Action: 当事件发生后，触发状态更新的代码
  const increment = () => {
    setCounter((prevCounter) => prevCounter + 1);
  };

  // View: 视图定义
  return (
    <>
      Value: {counter} <button onClick={increment}>Increment</button>
    </>
  );
}


export default Counter;